package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserRechargeableCardConsumeRequest extends Request {

	private Integer userId;

	private String rechargeCard;

	private String cardPasswd;
	
	private String rechargeFrom;

	public UserRechargeableCardConsumeRequest() {
	}

	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.rechargeCard = requestInfo.getParameter(ApiUrlParamEnum.rechargeCard.getParamName());
		this.cardPasswd = requestInfo.getParameter( ApiUrlParamEnum.password.getParamName(), "");
		this.rechargeFrom = requestInfo.getParameter(ApiUrlParamEnum.rechargeFrom.getParamName(), "");
		
		if (userId < 1) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if (StringUtil.isEmpty(rechargeCard)) {
			throw new RequestIllegalException("error ,  rechargeMoney is null ");
		}
		if (StringUtil.isEmpty(cardPasswd)) {
			throw new RequestIllegalException("error ,  cardPasswd is null ");
		}
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getRechargeCard() {
		return rechargeCard;
	}

	public void setRechargeCard(String rechargeCard) {
		this.rechargeCard = rechargeCard;
	}

	public String getCardPasswd() {
		return cardPasswd;
	}

	public void setCardPasswd(String cardPasswd) {
		this.cardPasswd = cardPasswd;
	}

	public String getRechargeFrom() {
		return rechargeFrom;
	}

	public void setRechargeFrom(String rechargeFrom) {
		this.rechargeFrom = rechargeFrom;
	}

	
}
